<?php
/*
 * @分销商城
 * @功能说明：首页栏目
 * @更新说明：暂无更新
 * @文件名 IndexController.class.php
 * @编码 UTF-8
 * @创建时间 2016-3-7 下午12:32:58
 * @创建人 XING
 */

namespace wap\Controller;
class IndexController extends ApibaseController
{
    /*
	 * 分销商城_首页模块
	 * @date: 2016-3-7 下午12:33:15
	 * @editor: XING
	 */
	public function index(){
		/*热销商品*/
		if(I('get.hotAjax')){
			$html = '';$page = I('get.page') ?: 1;
			$hotGoods = M('GoodsEntity')->where(array('delete_at'=>'0','status'=>'1','type'=>'1'))->where('kcun > 0')
					  ->order(array('sort'=>'desc'))->page($page,10)->select();
			if($hotGoods){
				foreach($hotGoods AS $key=>$val){
					if(!($key%2)){
						$html .= '</ul><ul>';
					}
					$html .= '<li><a href="/goods/detail/id/'.$val["goods_id"].'/sek/'.I('get.sek').'">
					<img class="lazys" src="/statics/images/lazy.png" data-original="'.transUrl($val['goods_pic']).'" width="100%"></a>
					<p><a href="/goods/detail/id/'.$val["goods_id"].'">'.$val["goods_title"].'</a></p>
					<p class="pay"><span class="icon-gouwu2" onclick="putCart(this)"></span>¥'.$val["goods_price"].'</p><input type="hidden" value="'.$val['goods_id'].'" class="goodsId" /></li>';
					if(!isset($hotGoods[$key+1])){
						$html .= '</ul>';
					}
				}
				
				echo json_encode(array('code'=>'1','msg'=>'success','data'=>$html,'page'=>$page));exit;
			}else{
				echo json_encode(array('code'=>'0','msg'=>'success','data'=>'','page'=>$page));exit;
			}
		}
		forLegal($this->realSek);
		/*幻灯数据*/
		$slideMain = M('SlideContent')
				   ->where(array('slide_id'=>'1'))->order(array('add_at'=>'desc'))->select();
		/*分类数据*/
		$cateEntity = M('CateEntity')
				    ->where(array('spread_status'=>'1'))->order(array('sort'=>'desc'))->limit(4)->select();
		
		/*最新上线*/
		$lastGoods = M('GoodsEntity')->where(array('status'=>'1','type'=>'1','delete_at'=>'0'))->where('kcun > 0')
				   ->order(array('add_at'=>'desc'))->limit(6)->select();
		$this->assign('lastGoods',$lastGoods);
		$this->assign('cateEntity',$cateEntity);
		$this->assign('slideMain',$slideMain);
    	$this->display('index/index');
	}
	
    /*
	 * 分销商城_买家用户中心
	 * @date: 2016-3-15 下午3:58:42
	 * @editor: XING
	 */
	public function user(){
		$this->display('index/user');
	}

}
